@extends('../manage.layout')
@section('content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            内容管理
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
            <li class="active">Here</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <button type="submit" class="btn btn-danger">批量删除</button> <button type="submit" class="btn btn-primary">批量导出</button>
                    </div>
                    <!-- table start -->
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <h3 class="box-title">分类列表</h3>

                                    <div class="box-tools">
                                       {{-- <div class="input-group input-group-sm" style="width: 150px;">
                                            <input type="text" name="table_search" class="form-control pull-right" placeholder="Search">

                                            <div class="input-group-btn">
                                                <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                                            </div>
                                        </div>--}}
                                    </div>
                                </div>
                                <!-- /.box-header -->
                                <div class="box-body table-responsive no-padding">
                                    <table class="table table-hover">
                                        <tr>
                                            <th><input type="checkbox" value=""></th>
                                            <th>ID</th>
                                            <th>分类名称</th>
                                            <th>创建时间</th>
                                            <th>更新时间</th>
                                            <th>操作</th>
                                        </tr>
                                        @foreach($categorys as $category)
                                        <tr>
                                            <td><input type="checkbox" value="{{ $category->id }}"></td>
                                            <td>{{ $category->id }}</td>
                                            <td>{{ $category->name }}</td>
                                            <td>{{ $category->create_time }}</td>
                                            <td>{{ $category->update_time }}</td>
                                            <td><a href="category/{{ $category->id }}/edit"><span class="label label-primary">更改</span></a>&nbsp;&nbsp;<a href="javascript:delSubscribe({{ $category->id }})"><span class="label label-danger">删除</span></a></td>
                                        </tr>
                                            @foreach($categorys as $son)
                                                @if($category->id == $son->parent)
                                                <tr>
                                                    <td><input type="checkbox" value="{{ $category->id }}"></td>
                                                    <td>{{ $son->id }}</td>
                                                    <td> &nbsp;&nbsp;&nbsp;&nbsp;⠧{{ $son->name }}</td>
                                                    <td>{{ $son->create_time }}</td>
                                                    <td>{{ $son->update_time }}</td>
                                                    <td><a href="category/{{ $son->id }}/edit"><span class="label label-primary">更改</span></a>&nbsp;&nbsp;<a href="javascript:delSubscribe({{ $son->id }})"><span class="label label-danger">删除</span></a></td>
                                                </tr>
                                                @endif
                                            @endforeach

                                        @endforeach
                                    </table>
                                </div>
                                <!-- /.box-body -->
                            </div>
                            <!-- /.box -->
                        </div>
                    </div>
                    <!-- /.table -->
                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->
@endsection
@section('script')
@endsection
<script>
    function delSubscribe(id) {
        layer.confirm('删除不可恢复，是否继续？', {
           btn:['确定','取消'] //按钮
        }, function() {
            $.post("{{ url('manage/category/') }}/"+id,{'_method':'delete','_token':"{{ csrf_token() }}"},function(data){
                if(data.status==0) {
                    layer.msg(data.msg, {time:1500, icon:5});
                } else {
                    layer.msg(data.msg, {time:1500, icon:6});
                    window.location.href = "/manage/category/";
                }
            });
        }, function() {

        });
    }
</script>